package com.amsp.oa.oademo.controller;

import com.amsp.oa.oademo.entity.Yijipgb;
import com.amsp.oa.oademo.service.YijipgbService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/yijipgb")
@Api(tags = "一级评估输出指引表管理")
@CrossOrigin
public class YijipgbController {

    @Autowired
    private YijipgbService yijipgbService;

    @PostMapping("/saveOrUpdate")
    @ApiOperation("保存或更新一级评估表")
    public boolean saveOrUpdate(@RequestBody Yijipgb yijipgb) {
        return yijipgbService.saveOrUpdate(yijipgb);
    }

    @PostMapping("/batchSaveOrUpdate")
    @ApiOperation("保存或更新一级评估表")
    public boolean batchSaveOrUpdate(@RequestBody List<Yijipgb> yijipgb) {
        return yijipgbService.saveOrUpdateBatch(yijipgb);
    }

    @GetMapping("/getPage")
    @ApiOperation("分页查询一级评估表")
    public IPage<Yijipgb> getPage(
            @ApiParam("当前页") @RequestParam(defaultValue = "1") Integer current,
            @ApiParam("每页大小") @RequestParam(defaultValue = "10") Integer size,
            @ApiParam("学员姓名") @RequestParam(required = false) String studentName,
            @ApiParam("学员工号") @RequestParam(required = false) String studentId,
            @ApiParam("部门") @RequestParam(required = false) String department) {
        return yijipgbService.getPage(current, size, studentName, studentId, department);
    }

    @GetMapping("/getInfo/{id}")
    @ApiOperation("根据ID查询一级评估表")
    public Yijipgb getInfo(@PathVariable Long id) {
        return yijipgbService.getById(id);
    }

    @DeleteMapping("/remove/{id}")
    @ApiOperation("根据ID删除一级评估表")
    public boolean removeById(@PathVariable Long id) {
        return yijipgbService.removeById(id);
    }

    @PostMapping("/batchRemove/{id}")
    @ApiOperation("根据ID删除一级评估表")
    public boolean batchRemove(@RequestBody List<Long> ids) {
        return yijipgbService.removeBatchByIds(ids);
    }
}